package top.yuki;




import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.plugin.java.JavaPlugin;
import top.yuki.Runnable.AutoRefreshEssence;
import top.yuki.command.CommandHandler;
import top.yuki.data.DataManager;
import top.yuki.data.DayDataManager;
import top.yuki.data.TempDataManage;
import top.yuki.event.*;
import top.yuki.setting.FileManager;
import top.yuki.data.WorldManage;

public class LevelWorld extends JavaPlugin implements Listener {
    public static LevelWorld instance ;
    public static FileManager fileManager;
    public static DataManager dataManage;
    public static WorldManage worldManage;
    public static TempDataManage tempDataManage;
    public static DayDataManager dayDataManager;
    public AutoRefreshEssence autoRefreshEssence;
    public ConfigurationSection config = null;
    @Override
    public void onEnable() {
        // Plugin startup logic
        instance = this;
        getLogger().info("LevelWorld插件开启");
        config = this.getConfig();
        fileManager = FileManager.init(this);
        fileManager.generate();
        dataManage = DataManager.init(this);
        worldManage = WorldManage.init(this);
        worldManage.generate();
        tempDataManage = TempDataManage.init(this);
        dayDataManager = DayDataManager.init(this);


        autoRefreshEssence = AutoRefreshEssence.init(this);
        autoRefreshEssence.start();


        Bukkit.getPluginManager().registerEvents(this,this);
        Bukkit.getPluginManager().registerEvents(new onPlayerJoin(this),this);
        Bukkit.getPluginManager().registerEvents(new onPlayerExpChange(this),this);
        Bukkit.getPluginManager().registerEvents(new onPlayerWorldChange(this),this);
        Bukkit.getPluginManager().registerEvents(new onCreatureSpawn(this),this);
        Bukkit.getPluginManager().registerEvents(new onMobDeath(this),this);
        Bukkit.getPluginManager().registerEvents(new onMobDamage(this),this);
        Bukkit.getPluginManager().registerEvents(new Inventory(this),this);
        Bukkit.getPluginCommand("levelworld").setExecutor(new CommandHandler());
    }

    @Override
    public void onDisable() {
        // Plugin shutdown logic
        dataManage.save();
        dayDataManager.save();

        getLogger().info("LevelWorld插件关闭，关闭服务器");

    }







}
